public class demo1 {
    public static void main(String[] args) {

        int s=FirstUniqueChar("bbsf");
        System.out.println(s);
    }

    public  static int FirstUniqueChar(String s){
        int[]count=new int[25];//计数数组
        if(s==null){
              return -1;
          }
        for (int i = 0; i <s.length() ; i++) {
                char ch=s.charAt(i);
                count[ch-'a']++;//[]里的字符会转为ASCII码值

        }
        for (int i = 0;  i<s.length() ; i++) {
            char ch=s.charAt(i);
            if(count[ch-'a']==1){
                return i;
            }
        }
        return -1;
    }
}
